﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.PO;
using Com.CMS263.BLL;
using Com.CMS263.Util;

namespace Com.CMS263.Web.manage.ManageArtType
{
    public partial class mod : System.Web.UI.Page
    {
        ArtTypeBLL bll = new ArtTypeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            int typeId = int.Parse(Request["typeId"]);
            if (!this.IsPostBack)
            {
                this.Bind(typeId);
            }
        }
        void Bind(int typeId)
        {
            ArtType at = bll.GetArtTypeById(typeId);
            this.txtOrderId.Text = at.orderId.ToString();
            this.txtTypeName.Text = at.typeName;
            this.hdfPid.Value = at.id.ToString();
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string typeName = this.txtTypeName.Text;
            int orderId = int.Parse(this.txtOrderId.Text);
            if (string.IsNullOrEmpty(typeName))
            {
                StringUtil.Alert("请填写类名","-1");
            }
            ArtType at = bll.GetArtTypeById(int.Parse(this.hdfPid.Value));
            at.typeName = typeName;
            at.orderId = orderId;
            bll.Modify(at);
            string menu = bll.GetTypeTree();
            FileUtil.WriteToFile(Server.MapPath("/manage/menutext/menu.txt"), menu);
            StringUtil.Alert("修改成功","AddSubType.aspx?typeId="+at.pid);


        }
    }
}
